Skip to content

ci: Add env vars for split units in sdk-platform-java#12765

Draft
lqiu96 wants to merge 1 commit intomainfrom
fix-split-units-env-var
Draft

ci: Add env vars for split units in sdk-platform-java#12765
lqiu96 wants to merge 1 commit intomainfrom
fix-split-units-env-var

Conversation

@lqiu96
Copy link
Copy Markdown
Member

@lqiu96 lqiu96 commented Apr 11, 2026

No description provided.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies Slf4jUtils to dynamically check for logging enablement at runtime instead of using a static final field. The associated unit tests were updated to toggle the logging state using a try-finally block. Feedback suggests improving test isolation by using @ResourceLock or a JUnit 5 extension to avoid potential race conditions when modifying global static state during parallel test execution.

Comment on lines +60 to +69
boolean originalValue = LoggingUtils.isLoggingEnabled();
try {
LoggingUtils.setLoggingEnabled(false);
Logger logger = Slf4jUtils.getLogger(Slf4jUtilsTest.class);
assertEquals(NOPLogger.class, logger.getClass());
assertFalse(logger.isInfoEnabled());
assertFalse(logger.isDebugEnabled());
} finally {
LoggingUtils.setLoggingEnabled(originalValue);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Modifying global static state via LoggingUtils.setLoggingEnabled(false) in a test can lead to flakiness and race conditions when tests are executed in parallel. While the try-finally block ensures the state is restored, it does not isolate this test from other concurrent tests that may rely on the same global state. Consider using a more isolated approach, such as a JUnit 5 extension or @ResourceLock, to manage shared state safely.

References
  1. Ensuring thread safety and avoiding race conditions is critical for reliable execution, especially in environments where tasks or tests may run concurrently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant